package com.xbongbong.schedule.controller;

import com.xbongbong.schedule.service.ScheduleTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class RoundPollingController {

    private static final Logger LOG = LoggerFactory.getLogger(RoundPollingController.class);

    @Resource
    private ScheduleTaskService scheduleTaskService;

    /**
     * 每隔半小时进行轮询
     */
//    @Scheduled(fixedRate = 1800000)
    @Scheduled(fixedRate = 60000)
    public void pollingScheduleTask() {
        try {
            scheduleTaskService.roundPollingScheduleTask();
        } catch (Exception e) {
            LOG.error("RoundPollingController-轮询报错：{}", e.getMessage());
        }
    }
}
